#!/usr/bin/env python
# -*- coding: utf-8 -*-
#

import	os, os.path
import	tempfile

import	unittest

import	zxstore.storecell as storecell

class	TestStoreCell(unittest.TestCase) :
	
	def	setUp(self) :
		tmpdir = tempfile.gettempdir()
		if tmpdir is None :
			raise RuntimeError, 'invalid tmpdir'
		store_path = tmpdir + os.sep + 'storem' + os.sep + 'cell'
		if os.path.isdir(store_path) :
			import	glob
			files = glob.glob(store_path + os.sep + '*.*')
			for file in files :
				os.remove(file)
		else :
			os.makedirs(store_path, 0777)
		self.cell = storecell.create(store_path)
		
	def	testInsert(self) :
		key = 'key0001'
		value = 'value0001'
		self.cell.insert(key, value)
		v = self.cell.find(key)
		self.assertEqual(value, v, 'FIND after INSERT key "%s" : expect "%s", but return "%s" ' % (key, value, v))


if	__name__ == '__main__' :
	unittest.main()

